/*
 * Copyright (c) 2016. Beijing Bo Yue Technology Co., Ltd.
 * All Right Reserved.
 */

package com.siemens.industrial.utils;

import java.util.HashMap;
import java.util.Map;

public enum GlobalResponseCode {
    SUCCESS,
    ERROR_INVALID_SMS_TOKEN,
    ERROR_LOGIN_FAILED,
    ERROR_SMS_REQUEST_LOAD_EXCEEDED,

    //Exception
    ERROR_Exception_ParseException,

    //IO Exception
    ERROR_FILE_NOT_FOUND,
    ERROR_FILE_IN_USE,

    // USER AUTHENTICATION
    ERROR_UNAUTHORIZED,
    ERROR_ACCESS_TOKEN_EXPIRED,
    ERROR_REFRESH_TOKEN_EXPIRED,

    // USER REGISTRATION
    ERROR_USER_EXISTED,
    ERROR_USER_NOT_EXISTED,

    // EVENT
    ERROR_EVENT_NOT_EXISTED,
    ERROR_EVENT_EXISTED,

    //SHIFT
    ERROR_SHIFT_NOT_EXISTED,
    ERROR_SHIFT_EXISTED,

    //Metadata
    ERROR_METADATA_NOT_EXISTED,
    ERROR_METADATA_EXISTED,

    //IDLE
    ERROR_IDLE_NOT_EXISTED,
    ERROR_IDLE_EXISTED,
    ERROR_CREATE_REASON_FAIL,

    //SUBSCRIPTION
    ERROR_SUBSCRIPTION_NOT_EXISTED,
    ERROR_SUBSCRIPTION_EXISTED,

    //DeviceState
    ERROR_STATE_NOT_EXISTED,
    ERROR_STATE_EXISTED,
    ERROR_STATE_NOT_EXISTED_OR_NOT_WORK,

    //Device
    ERROR_DEVICE_NOT_EXISTED,
    ERROR_DEVICE_EXISTED,

    // IMAGE
    ERROR_FILE_UPLOAD_FAILED,
    ERROR_CREATE_DIR_FAILED,
    ERROR_CREATE_FILE_FAILED,
    ERROR_IMAGE_NOT_FOUND,
    ERROR_UNSUPPORTED_STORAGE_ENGINE,

    // USER Create
    ERROR_USER_NOT_CREATE,

    //USER ChangePass
    ERROR_INCORRECT_PASSWORD,
    ERROR_RESET_PASSWORD_FAIL,

    //AUTHORITY
    ERROR_AUTHORITY_INVALID,
    //Tenant Create
    ERROR_TENANT_NOT_CREATE,

    //Product
    ERROR_PRODUCT_NOT_EXISTED,
    ERROR_PRODUCT_MODIFY_FAIL,
    ERROR_PRODUCT_CREATE_FAIL,

    //GateWay
    ERROR_AD_DATA_NOT_EXISTED,
    ERROR_ACC_DATA_NOT_EXISTED,

    //DBBackup
    ERROR_SETTING_DBBACKUP,
    ERROR_DBBACKUP_IMMEDIATELY_FAIL,

    //mail
    ERROR_MAIL_SEND_FAIL,
    ERROR_MAIL_NOT_SERVER_SETTINGS,

    //export
    ERROR_EXPORT_FILE_FAIL;

    private static final Map<GlobalResponseCode, String> messages = new HashMap<GlobalResponseCode, String>() {{
        put(SUCCESS, "The operation is finished successfully.");
        put(ERROR_INVALID_SMS_TOKEN, "The SMS Token is invalid");
        put(ERROR_LOGIN_FAILED, "Login Failed");
        put(ERROR_UNAUTHORIZED, "Unauthorized");
        put(ERROR_ACCESS_TOKEN_EXPIRED, "Access Token is expired. Please use refresh token to exchange new token.");
        put(ERROR_REFRESH_TOKEN_EXPIRED, "Refresh Token is expired. Please login again.");
        put(ERROR_USER_EXISTED, "User already existed.");
        put(ERROR_USER_NOT_EXISTED, "User not existed.");
        put(ERROR_SMS_REQUEST_LOAD_EXCEEDED, "The SMS verification exceed its max load");
        put(ERROR_CREATE_DIR_FAILED, "Create directory failed");
        put(ERROR_CREATE_FILE_FAILED, "Create file failed");
        put(ERROR_FILE_UPLOAD_FAILED, "Upload failed");
        put(ERROR_IMAGE_NOT_FOUND, "Image does not found!");
        put(ERROR_UNSUPPORTED_STORAGE_ENGINE, "Unsupported Image Storage Engine");
        put(ERROR_USER_NOT_CREATE, "Create user failed");
        put(ERROR_INCORRECT_PASSWORD, "Password Error");
        put(ERROR_AUTHORITY_INVALID, "Authority is invalid!");
        put(ERROR_Exception_ParseException, "Int change Long Error!");
        put(ERROR_FILE_NOT_FOUND, "File not found!");
        put(ERROR_FILE_IN_USE, "File in use!");
        put(ERROR_EVENT_NOT_EXISTED, "Event not exist!");
        put(ERROR_EVENT_EXISTED, "Event already exist!");
        put(ERROR_SHIFT_NOT_EXISTED, "Shift not exist!");
        put(ERROR_SHIFT_EXISTED, "Shift already exist!");
        put(ERROR_METADATA_NOT_EXISTED, "Metadata not exist!");
        put(ERROR_METADATA_EXISTED, "Metadata already exist!");
        put(ERROR_IDLE_NOT_EXISTED, "Idle not exist!");
        put(ERROR_IDLE_EXISTED, "Idle already exist!");
        put(ERROR_SUBSCRIPTION_NOT_EXISTED, "Subscription not exist!");
        put(ERROR_SUBSCRIPTION_EXISTED, "Subscription already exist!");
        put(ERROR_STATE_NOT_EXISTED, "State not exist!");
        put(ERROR_STATE_EXISTED, "State already exist!");
        put(ERROR_DEVICE_NOT_EXISTED, "Device not exist!");
        put(ERROR_DEVICE_EXISTED, "Device already exist!");
        put(ERROR_TENANT_NOT_CREATE,"Tenant or key already exist");
        put(ERROR_PRODUCT_NOT_EXISTED,"Product not exist!");
        put(ERROR_PRODUCT_MODIFY_FAIL,"Product modify fail");
        put(ERROR_STATE_NOT_EXISTED_OR_NOT_WORK,"Device state not existed or not working");
        put(ERROR_PRODUCT_CREATE_FAIL,"Product create fail");
        put(ERROR_CREATE_REASON_FAIL,"Offline reasons add failure");
        put(ERROR_PRODUCT_CREATE_FAIL,"Product create fail");
        put(ERROR_AD_DATA_NOT_EXISTED,"AD data is null");
        put(ERROR_ACC_DATA_NOT_EXISTED,"ACC data is null");
        put(ERROR_SETTING_DBBACKUP,"Setting DBBackup fail");
        put(ERROR_MAIL_SEND_FAIL,"Send mail fail");
        put(ERROR_MAIL_NOT_SERVER_SETTINGS,"The mail server is not settings");
        put(ERROR_RESET_PASSWORD_FAIL,"Reset password fail");
        put(ERROR_DBBACKUP_IMMEDIATELY_FAIL,"DBBackup immediately fail");
        put(ERROR_EXPORT_FILE_FAIL,"Export fail");
    }};

    public String getMessage() {
        return messages.get(this);
    }
}
